/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Stateless;

/**
 *
 * @author Anneleen
 */
@Stateless
public class StatelessBean implements StatelessBeanLocal {

    @Override
    public String queryString(String query) {
        return "The following query was executed: " + query + " at " + getDate();
    }

    @PostConstruct
    @Override
    public void initialize() {
        System.out.println("Stateless bean is created: " + getDate());
    }
        
    @PreDestroy
    @Override
    public void destroy() {
        System.out.println("Stateless bean is destroyed: " + getDate());
    }

    @Override
    public String getDate() {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        return dateFormat.format(date);
    }
}
